package com.entity;

import com.mike.median.util.PokerList;

/**
 * 牌型分类
 * <strong>将5张牌按牌型进行分类,并算出序列pokerNum,序列用于在相同牌型下进行比较</strong>
 * @see POKER_TYPE_ENUM
 */
public class PokerType implements Comparable {
    private PokerList<Poker> pokers;
    private POKER_TYPE_ENUM poker_type_enum;
    private long pokerNum;

    public POKER_TYPE_ENUM getPoker_type_enum() {
        return poker_type_enum;
    }

    public void setPoker_type_enum(POKER_TYPE_ENUM poker_type_enum) {
        this.poker_type_enum = poker_type_enum;
    }

    public long getPokerNum() {
        return pokerNum;
    }

    public void setPokerNum(long pokerNum) {
        this.pokerNum = pokerNum;
    }

    public PokerList<Poker> getPokers() {
        return pokers;
    }

    public void setPokers(PokerList<Poker> pokers) {
        this.pokers = pokers;
    }

    public static enum POKER_TYPE_ENUM {
        同花顺(8), 炸弹(7), 满堂彩(6), 清一色(5), 一条龙(4), 三条(3), 两对(2), 一对(1), 普通(0);
        private int pokerType;

        POKER_TYPE_ENUM(int pokerType) {
            this.pokerType = pokerType;
        }

        public int getPokerType() {
            return pokerType;
        }
    }

    public PokerType(PokerList<Poker> pokers) {
        this.pokers = pokers;
    }

    @Override
    public int compareTo(Object o) {
        PokerType that = (PokerType) o;
        if (this.poker_type_enum.getPokerType() - that.poker_type_enum.getPokerType() == 0) {
            return (int) (this.pokerNum - that.pokerNum);
        } else {
            return this.poker_type_enum.getPokerType() - that.poker_type_enum.getPokerType();
        }
    }

    @Override
    public String toString() {
        return "PokerType{" +
                "pokers=" + pokers +
                ", poker_type_enum=" + poker_type_enum +
                ", pokerNum=" + pokerNum +
                '}';
    }
}
